<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>计算成本均价</title>
  </head>
  <body>
    <script type="text/javascript">
      Ext.onReady(function(){
        //要求发货时间
        var actionDate = new Ext.form.DateField({
          fieldLabel: '成本截止年月',
          name: 'action_date',
          format: 'Y-m', //格式化日期
          //disabledDays: [0,6],	//不让选择周六，周日
          //disabledDaysText: "周末要休息",
          invalidText: "您输入的日期格式不对，正确格式为2010-01-18",
          allowBlank: false,
          blankText: "发货日期必须选择",
          emptyText: '发货日期...',
          anchor: '95%'
        });

        var calCostAndTaxButton = new Ext.Button({
          text: '计算成本及含税成本均价',
          handler: function(){
            if (priceFormPanel.form.isValid()) {
              Ext.MessageBox.confirm("提示","你确认要计算成本均价吗？",function(btn){
                if(btn=="yes"){
                  calCostAndTaxButton.disable();
                  Ext.Ajax.request({
                    url : '/admin/calCostPrice',
                    timeout: 120000,
                    success : function (result, request) {
                      Ext.Msg.alert('提示信息','计算成本均价完成！');
                      calCostAndTaxButton.enable();
                    },
                    failure : function (result, request){
                      Ext.MessageBox.show({
                        title: '消息',
                        msg: "通讯失败，请从新操作",
                        buttons: Ext.MessageBox.OK,
                        icon: Ext.MessageBox.WARNING
                      });
                    },
                    method : 'GET',
                    params : {
                      action_date : actionDate.getRawValue()
                    }
                  });
                }else{

                }
              });
            }
          }
        })

        var priceFormPanel = new Ext.form.FormPanel({
          //baseCls: 'x-plain',
          //renderTo: 'query_form',
          labelWidth: 85,
          width: screenWidth-175,
          labelAlign: 'right',
          frame : true,
          border:false,
          items: [{
              xtype: 'fieldset',
              defaults: {width: 1100},
              title: '查询条件',
              border: true,
              items: [{
                  layout: 'column',
                  border: false,
                  items: [{
                      columnWidth: .18,
                      layout: 'form',
                      border: false,
                      items: [actionDate]
                    }, {
                      columnWidth: .15,
                      layout: 'form',
                      border: false,
                      items: [calCostAndTaxButton]
                    }]
                }]
            }]
        });

        priceFormPanel.render('cal_cost_price');
        
        var newFormPanel = new Ext.form.FormPanel({
          labelWidth: 45,
          width: 300,
          labelAlign: 'right',
          buttonAlign: 'center',
          frame : true,
          buttons: [calCostAndTaxButton]
        });
      })
    </script>
    <div id="cal_cost_price"></div>
  </body>
</html>